#!/bin/bash
#PBS -N be.cpu
#PBS -j oe
#PBS -q parallel
#PBS -l walltime=00:30:00,nodes=8:ppn=2
#PBS -A UT-NTNL0052

export myexe=/gpfs/medusa/jnkim2/qmcpack-cur/build/bin/qmcapp

module swap openmpi mvapich2
module list
export MV2_ENABLE_AFFINITY=0

date
cd $PBS_O_WORKDIR

echo "nodefile="
cat $PBS_NODEFILE
echo "=end nodefile"

export NP=`cat $PBS_NODEFILE | wc -l`
export OMP_NUM_THREADS=6

vmc_blocks=100
let dmc_samples=$NP*$OMP_NUM_THREADS*$vmc_blocks
let opt_samples=$NP*$OMP_NUM_THREADS*$vmc_blocks
dmc_blocks=250
dmc_dt=0.02

export title=be.cpu.p${NP}x${OMP_NUM_THREADS}.`date +"%m-%d-%y_%H%M"`

export twist=0
export WFSXML_IN=be16.a4.6.opt.wfs.xml
WFSXML=be.k$twist.wfs.xml
cat $WFSXML_IN | sed s/TWIST/$twist/ > $WFSXML


#----------------------------
# for Main
#----------------------------
cat qmc.xml\
| sed s/TITLE/$title/ \
| sed s/WFSXML/$WFSXML/ \
| sed s/VMCBLOCKS/$vmc_blocks/ \
| sed s/VMCSTEPS/10/ \
| sed s/WALKERS/1/ \
| sed s/SAMPLES/$dmc_samples/ \
| sed s/DMCBLOCKS/$dmc_blocks/ \
| sed s/TIMESTEP/$dmc_dt/ \
> $title.xml

# run the program
mpiexec ${myexe} $title.xml &> $title.qmc.log

